package com.chushouya.controller.manager.admin;

import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.enums.BusinessType;
import com.general.framework.core.schema.PageResult;
import com.general.framework.core.schema.Response;
import com.general.framework.web.annotations.Log;
import com.chushouya.manager.dto.admin.attachment.AttachmentListDTO;
import com.chushouya.manager.dto.admin.attachment.AttachmentQuery;
import com.chushouya.manager.service.admin.AttachmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 附件管理
 */
@RestController
@RequestMapping(ServiceType.PLATFORM + "/attachment")
@Api(tags = "platform附件管理")
public class AttachmentController {

    @Resource
    private AttachmentService attachmentService;

    @GetMapping("/page")
    @ApiOperation("查询附件列表")
    public Response<PageResult<AttachmentListDTO>> page(AttachmentQuery query) {
        return Response.success(attachmentService.selectPage(query));
    }

    @PostMapping("/remove")
    @ApiOperation("删除附件")
    @Log(businessType = BusinessType.DELETE)
    public Response<Void> remove(Long attachmentId) {
        attachmentService.remove(attachmentId);
        return Response.success();
    }

}
